<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>修改密码</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="${pageContext.request.contextPath}/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/css/animate.min.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/css/style.min.css?v=4.1.0" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/jQuery-Validation/css/validationEngine.jquery.css" rel="stylesheet">
</head>

<body class="gray-bg">
<div class="formErrorContent"></div>
<shiro:hasRole name="admin">
<div class="container">
	<form class="form-horizontal" role="form" id="setUpWdPassForm" autocomplete="off">
	    <input type="hidden" id="userId" name="id">
	    <div class="form-group" style="margin-top:20px; ">
	        <div class="col-sm-4">
	            <input type="password" maxlength="6" style="font-size:22px;"
	            	class="form-control validate[required,minSize[6],maxSize[6],custom[onlyNumberSp]]" name="wdPwd" id="wdPwd" placeholder="6位纯数字密码" autocomplete='new-password'>
	        </div>
	    </div>
	    <div class="form-group">
	        <div class="col-sm-6 control-label" style="text-align:center !important;">
	             &nbsp;&nbsp;&nbsp;&nbsp;<button type="submit" class="btn btn-primary"  id="setUpWdPassBtn">确认保存</button>
	        </div>
	    </div>
	</form>
</div>
</shiro:hasRole>
<shiro:lacksRole name="admin">
	<div style="width: 600px;margin: 200px auto;">
		<img src="${pageContext.request.contextPath}/img/quanxian.png" width="600px">
	</div>
</shiro:lacksRole>
<script src="${pageContext.request.contextPath}/js/jquery.min.js?v=2.1.4"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js?v=3.3.6"></script>
<script src="${pageContext.request.contextPath}/js/content.min.js?v=1.0.0"></script>
<script src="${pageContext.request.contextPath}/js/plugins/layer/layer.min.js"></script>
<script src="${pageContext.request.contextPath}/js/public/ttbj-core.js"></script>
<script src="${pageContext.request.contextPath}/jQuery-Validation/js/jquery.validationEngine.js"></script>
<script src="${pageContext.request.contextPath}/jQuery-Validation/js/jquery.validationEngine-zh_CN.js"></script>
<script type="text/javascript">
<shiro:hasRole name="admin">
//验证是否输入
$(function () {
	$('#setUpWdPassForm').validationEngine('attach', {
	    validationEventTrigger : 'blur',	//当提交的时候验证是否合法
	    promptPosition: 'inline',
	    scroll: false,
	    focusFirstField : true,
	    autoPositionUpdate:true,
	    onValidationComplete : function (form, valid) {
	    	if(valid){
	    		setUpWdPwd();
	    	}
	    }
	});
});

//设置提现密码
function setUpWdPwd(){
	var wdPassword = $.trim($('#wdPwd').val());
	$.ajax({
		url: "../withdraw/setUpComnumWpassword.htm",
		cache: false,
		async : false,
		type: "post",
		dataType: "json",
		data:{"wdPassword":wdPassword},
		beforeSend:function(){var index = layer.load(1, { shade: [0.8,'#ddd']});},
        complete:function(){var index = layer.closeAll("loading");},
		success: function (result) {
		    if (result.status == 0) {	//如果正常返回，则显示出值
		        parent.layer.msg(result.message, {icon: 1});
		        closeForm();
		    }else {
		    	parent.layer.msg(result.message, {icon: 2});
		    }
		    return;
		}
	});
}

//关闭窗口
function closeForm() {
    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
    parent.layer.close(index);
}
</shiro:hasRole>
</script>
</body>
</html>